<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title }}</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="stylesheet" href="/static/css/base.css">
    <link rel="stylesheet" href="/static/css/common.css">
    <link rel="stylesheet" href="/static/css/detail.css">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="/static/script/base.js"></script>
</head>

<body>
    <!-- 快捷导航模块开始 -->
    <section class="shortcut">
        <div class="width">
            <div class="fl">
                <ul>
                    <li>食品网欢迎您！&nbsp;</li>
                    <li>
                        请<a href="/loginForm" class="style_green">登录</a>
                        <a href="/registerForm" class="style_green">&nbsp;免费注册</a>
                    </li>
                </ul>
            </div>
            <div class="fr">
                <ul>
                    <li>我的订单</li>
                    <li>|</li>
                    <li>我的食品网<span></span></li>
                    <li>|</li>
                    <li>食品网会员</li>
                    <li>|</li>
                    <li>关注我们<span></span></li>
                    <li>|</li>
                    <li>客户服务<span></span></li>
                    <li>|</li>
                    <li>网站导航<span></span></li>
                </ul>
            </div>
        </div>
    </section>
    <!-- 快捷导航模块结束 -->
    <!-- 头部制作模块开始 -->
    <header class="header width">
        <a href="/index" class="logo"></a>
        <div class="search">
            <input type="search" name="" id="id_key" placeholder="中华老字号">
            <button id="id_search">搜索</button>
        </div>
        <div class="hotwords">
            <a href="/search/?keyword=%E8%91%A1%E8%90%84%E9%85%92&page=0&size=10" class="style_red">葡萄酒</a>
            <a href="/search/?keyword=%E9%A5%BC%E5%B9%B2%E8%9B%8B%E7%B3%95&page=0&size=10">饼干蛋糕</a>
            <a href="/search/?keyword=%E7%81%AB%E8%85%BF&page=0&size=10">火腿</a>
            <a href="/search/?keyword=%E9%85%92%E6%9D%AF&page=0&size=10">酒杯</a>
            <a href="/search/?keyword=%E8%86%A8%E5%8C%96%E9%A3%9F%E5%93%81&page=0&size=10">膨化食品</a>
            <a href="/search/?keyword=%E6%B0%B4%E6%9E%9C&page=0&size=10">水果</a>
            <a href="/search/?keyword=%E7%8C%AA%E8%82%89&page=0&size=10">猪肉</a>
        </div>
    </header>
    <!-- 头部制作模块结束 -->
    <!-- 右侧边栏制作开始 -->
    <div class="sidebar">
        <ul class="box">
            <li class="user" id="id_acount">
                <a href="#">
                    <span></span>
                    账号
                </a>
            </li>
            <li class="shopping_bag">
                <a href="#" id="id_cart">
                    <span></span>
                    购物车<br>
                    <i class="count">8</i>
                </a>
            </li>
            <li class="order">
                <a href="#">
                    <span></span>
                    订单
                </a>
            </li>
            <li class="collection" id="id_collection">
                <a href="#">
                    <span></span>
                    收藏
                </a>
            </li>
            <li class="complaint">
                <a href="#">
                    <span></span>
                    投诉
                </a>
            </li>
            <li class="top">
                <a href="#top">
                    <span></span>
                </a>
            </li>
        </ul>
    </div>
    <!-- 右侧边栏制作结束 -->
    <!-- 商品详情信息开始 -->
    <div class="detail">
        <div class="crumb">
{#            <div class="width">#}
{#                <a href="#">新鲜水果</a>>#}
{#                <a href="#">莲雾</a>>#}
{#                <a href="#">海南莲雾500g装 单果约70-130g 新鲜时令水果 莲雾 500g装【净果5-7个】</a>#}
{#            </div>#}
            <div class="width">
                <a href="#">{{discription}}</a>
            </div>
        </div>
        <div class="width">
                <div class="leftcon" id="leftbox">
                    <img src={{img}} class="picl" id="img">
                    <div id="text" style="display:none; color: #e12228; margin-left: 200px;">点击查看大图</div>
                    <div class="mask"></div>
                </div>
                <div class="rightcon" id="rightbox">
                    <img src={{img}} id="id_g_img" class="picr" >
                </div>
                <div class="magnifier"></div>
            <div class="goods_detail_list">
                <h2>{{description}}</h2>
                <div class="prize_bar">
                    <span>价格：<i>¥ {{price}}</i></span>
                    <br>
                    <div class="num_add">
                        数量：
                        <input type="text" name="" id="amount" value=1>
                        <a  class="add"  href="javascript:void(0)" onclick="add()">+</a>
                        <a  class="reduce"  href="javascript:void(0)" onclick="minus()">-</a>
                        <a class="operate_btn" id= {{id}}>加入购物车</a>
                        
                    </div>
                    <div class="like">
                        <i></i>
                        <button class="col_btn" onclick="addCollection({{ id }})">收藏</button>
                    </div>
                </div>
            </div>
            <div class="info width">
                <div class="info_head">商品介绍
                </div>
                <ul class="info_body">
                    <li>商品名称：{{ title }}</li>
                    <li>商品库存：{{ storage }}</li>
                    <li>商品产地：海南</li>
                    <li>国产/进口：国产</li>
                </ul>
            </div>
        </div>
    </div>

    <!-- 商品详情信息结束 -->
    <!-- 底部模块开始 -->
    <footer class="footer">
        <div class="width">
            <div class="mod_service">
                <ul>
                    <li>
                        <div class="service_icon1"></div>
                        <div class="text">
                            <h3>品类齐全，轻松购物</h3>
                        </div>
                    </li>
                    <li>
                        <div class="service_icon2"></div>
                        <div class="text">
                            <h3>多仓直发，极速配送</h3>
                        </div>
                    </li>
                    <li>
                        <div class="service_icon3"></div>
                        <div class="text">
                            <h3>正品行货，精致服务</h3>
                        </div>
                    </li>
                    <li>
                        <div class="service_icon4"></div>
                        <div class="text">
                            <h3>天天低价，畅选无忧</h3>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="mod_help">
                <dl>
                    <dt>
                        <a href="#">服务指南</a>
                    </dt>
                    <dd><a href="#">购物流程</a></dd>
                    <dd><a href="#">会员介绍</a></dd>
                    <dd><a href="#">生活旅行/团购</a></dd>
                    <dd><a href="#">常见问题</a></dd>
                    <dd><a href="#">联系客服</a></dd>
                </dl>
                <dl>
                    <dt><a href="#">配送方式</a></dt>
                    <dd><a href="#">上门自提</a></dd>
                    <dd><a href="#">211限时达</a></dd>
                    <dd><a href="#">配送服务查询</a></dd>
                    <dd><a href="#">配送费收取标准</a></dd>
                    <dd><a href="#">海外配送</a></dd>
                </dl>
                <dl>
                    <dt><a href="#">支付方式</a></dt>
                    <dd><a href="#">货到付款</a></dd>
                    <dd><a href="#">在线支付</a></dd>
                    <dd><a href="#">分期付款</a></dd>
                    <dd><a href="#">公司转账</a></dd>
                </dl>
                <dl>
                    <dt><a href="#">售后服务</a></dt>
                    <dd><a href="#">售后政策</a></dd>
                    <dd><a href="#">价格保护</a></dd>
                    <dd><a href="#">退款说明</a></dd>
                    <dd><a href="#">返修/退换货</a></dd>
                    <dd><a href="#">取消订单</a></dd>
                </dl>
                <dl>
                    <dt><a href="#">特色服务</a></dt>
                    <dd><a href="#">夺宝岛</a></dd>
                    <dd><a href="#">DIY装机</a></dd>
                    <dd><a href="#">延保服务</a></dd>
                </dl>
                <dl>
                    <dt>帮助中心</dt>
                    <dd class="qrcode">
                        <img src="/static/images/QRcode.png" alt="">
                    </dd>
                    下载客户端
                </dl>
            </div>
            <div class="mod_copyright">
                <div class="links">
                    <a href="#">关于我们</a>|
                    <a href="#">联系我们</a>|
                    <a href="#">联系客服</a>|
                    <a href="#">商家入驻</a>|
                    <a href="#">营销中心</a>|
                    <a href="#">友情链接</a>|
                    <a href="#">销售联盟</a>|
                    <a href="#">食品网社区</a>|
                    <a href="#">English Site</a>|
                    <a href="#">Contact U</a>|
                </div>
                <div class="copyright">
                    地址：内蒙古师范大学盛乐校区 邮编：010000 电话：400-123-1234 传真：010-12345678 邮箱: 1234567@567.com</br>
                    蒙ICP备08001234号蒙公网安备110123456789
                </div>
            </div>
        </div>
    </footer>
    <!-- 底部模块结束 -->
    
</body>
    <script>
        $("#id_g_img").click(function () {
            //获取图片路径
            var imgsrc = $("#id_g_img").attr("src")
            console.log(imgsrc);
            var opacityBottom = '<div class="opacityBottom" style = "display:none"><img class="bigImg" src="' + imgsrc + '"></div>';
            $(document.body).append(opacityBottom);
            toBigImg();//变大函数
        });

        function toBigImg() {
            $(".opacityBottom").addClass("opacityBottom");//添加遮罩层
            $(".opacityBottom").show();
            $("html,body").addClass("none-scroll");//下层不可滑动
            $(".bigImg").addClass("bigImg");//添加图片样式
            $(".opacityBottom").click(function () {//点击关闭
                $("html,body").removeClass("none-scroll");
                $(".opacityBottom").remove();
            });
        }
        function add(){
            var amount=document.getElementById('amount').value;
            var i=parseInt(amount);
            i=i+1;
            document.getElementById("amount").value=i;

        }
        function minus(){
            var amount=document.getElementById('amount').value;
            var i=parseInt(amount);
            if(i-1!=0){
                i=i-1;
                document.getElementById("amount").value=i;
            }
        }

    </script>
    <script>
        var buy_btn = $(".operate_btn")
        buy_btn.click(function () {
            var amount =  document.getElementById("amount").value
            var id = buy_btn.attr("id")
            var data = {'goodsId':id,'amount':amount}
            $.ajax({
                url : "/order/add",
                type : "post",
                data: JSON.stringify(data),
                contentType:"application/json",
                success:function(){
                    alert("添加成功")
                }
            })
        })
    </script>
    <script>
        $("#id_search").click(function (){
            var key = $("#id_key").val()
            window.location.href = "/search?keyword="+key+"&page="+0+"&size="+10;
        })
    </script>
    <script>
        var addCollection = function (id) {
            $.ajax({
                url : "/goods/collection/add",
                type: 'get',
                data:{'id':id},
                success:function (result) {
                    alert(result.message)
                }
            })
        }
    </script>
    <script>
        (function()
            {
                var box=document.getElementById('text');
                var btn=document.getElementById('id_g_img');
                btn.onmouseover=function(){
                    box.style.display='block';
                }
                btn.onmouseout=function(){
                    box.style.display='none';
                }
            })()
    </script>
    <script>
         var leftcon = document.getElementById('leftbox');
         var rightcon = document.getElementById('rightbox');
         var mask = document.getElementsByClassName('mask')[0];
         var rpic = document.getElementsByClassName('picr')[0];
         function getPoint(e) {
            var e = e || window.event;
            var top = e.clientY - leftcon.offsetTop - mask.offsetHeight / 2;//计算方法如上图
            var left = e.clientX - leftcon.offsetLeft - mask.offsetWidth / 2;
            var maxtop = leftcon.offsetHeight - mask.offsetHeight; //获取小滑块最大纵向移动距离
            var maxleft = leftcon.offsetWidth - mask.offsetWidth;  //获取小滑块最大横向移动距离
            var mintop = 0;  //获取小滑块最小纵向移动距离
            var minleft = 0;  //获取小滑块最大纵向移动距离
            var mvtop;  //定义小滑块的纵向移动距离
            var mvleft;  //定义小滑块的横向移动距离
            if (top < mintop) {
                mask.style.top = mintop + "px";
                mvtop = mintop;
           } else if (top > maxtop) {
                 mask.style.top = maxtop + "px";
                 mvtop = maxtop;
           } else {
                 mask.style.top = top + "px";
                 mvtop = top;
            }
            if (left < minleft) {
                    mask.style.left = minleft + "px";
                    mvleft = minleft
           } else if (left > maxleft) {
                   mask.style.left = maxleft + "px";
                   mvleft = maxleft
           } else {
                   mask.style.left = left + "px";
                   mvleft = left;
           }
              rpic.style.top = -mvtop * 2 + "px";
              rpic.style.left = -mvleft * 2 + "px";
          }
            leftcon.onmouseover=function(e){
                 var e = e||window.event;
                 rightcon.style.display="block";
                 mask.style.display="block";
                 getPoint(e);
            }
            leftcon.onmouseout=function(e){
                  var e = e||window.event;
                  rightcon.style.display="none";
                  mask.style.display="none";
            }
            leftcon.onmousemove = function(e){
                var e=e||window.event;
                getPoint(e);
            }
    </script>
</html>
